package met.cs664.ai.cox.soc.strategies.placement;

import soc.game.SOCBoard;

/**
 * Abstract evaluator providing common functionality for all children
 *
 * @author mcox
 */
public abstract class AbstractEvaluator {

    /** Coord translation from a node to its NW hex */
    private static final int NODE_TO_NORTH_HEX = -0x10;

    /** Coord translation from a node to its NW hex */
    private static final int NODE_TO_NORTHWEST_HEX = -0x21;

    /** Coord translation from a node to its NE hex */
    private static final int NODE_TO_NORTHEAST_HEX = 0x01;

    /** Coord translation from a node to its NW hex */
    private static final int NODE_TO_SOUTHWEST_HEX = -0x12;

    /** Coord translation from a node to its NW hex */
    private static final int NODE_TO_SOUTHEAST_HEX = 0x10;

    /** Coord translation form a node to its S hex */
    private static final int NODE_TO_SOUTH_HEX = -0x01;

    protected float weight;

    protected AbstractEvaluator(float weight) {
        this.weight = weight;
    }

    protected float getWeight() {
        return weight;
    }

    protected void setWeight(float weight) {
        this.weight = weight;
    }

    /**
     * For a given node coordinate return neighboring hexes
     * @param nodeCoord the hex coordinate to locate
     * @return hex neighbors
     */
    protected int [] getAdjacentHexesToNode(int nodeCoord) {
        if ((nodeCoord & 1) == 0) {
            return new int [] {nodeCoord + NODE_TO_NORTHWEST_HEX, nodeCoord + NODE_TO_NORTHEAST_HEX, nodeCoord + NODE_TO_SOUTH_HEX};
        } else {
            return new int [] {nodeCoord + NODE_TO_SOUTHWEST_HEX, nodeCoord + NODE_TO_SOUTHEAST_HEX, nodeCoord + NODE_TO_NORTH_HEX};
        }


    }
}
